package cn.codeforfun.controller;

import cn.codeforfun.pojo.User;
import cn.codeforfun.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2017/2/28.
 */
@Controller
public class IndexController {
  @Autowired
  private IndexService indexService;


  @RequestMapping
  @ResponseBody
  public String index(String name) {
    System.out.println(name);
    return "index";
  }

  @RequestMapping("/home")
  @ResponseBody
  public String home(String name) {
    System.out.println(name);
    return "home";
  }

  @RequestMapping("/hello")
  @ResponseBody
  public String hello(String name) {
    System.out.println(name);
    return "hello";
  }

  @RequestMapping("/save")
  @ResponseBody
  public User save(@RequestBody User user) {
    indexService.save(user);
    return user;
  }
}
